import { getMenuList } from "../../request/api";
let state = {
    // 菜单列表数据
    menuListData: [],
}

let mutations = {
    modifyListData(state, value) {
        state.menuListData = value
    }
}

let actions = {
    
    // 获取菜单列表
    getMenuListData(context) {
        getMenuList().then(
            (res) => {
                if (res.data.code == 200) {
                    context.commit("modifyListData",res.data.list)
                }
            },
            (err) => err
        );
    },
    
}

let getters = {
    // 导出菜单列表数据
    menuListData(state){
        return state.menuListData
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    // 开启命名空间,防止重名
    namespaced: true
}